package org.example;

public class 第二十四章_封装 {
    public static void main(String[] args) {
        P1 p1 = new P1();
        p1.setAge(29);
        p1.setName("小明");
        System.out.println("名称: "+p1.getName()+",年龄: "+p1.getAge());
    }
}

class P1{
    private String name;//姓名
    private int age;//年龄

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }
}
